package com.lms.collection.list;

import java.util.Enumeration;
import java.util.Vector;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-05-26 07:10
 * @Description:
 */
public class VectorDemo {
    public static void main(String[] args) {
        //默认容量为10，扩容容量默认为0，表示扩容增加一倍容量
        Vector<Object> vector = new Vector<>();
        //指定容量为8，每次扩容增加4.
        Vector<Object> vector1 = new Vector<>(8, 4);
        boolean add = vector.add(1);
        vector.add(1);
        //这两个方法是一样 的
        vector.add(2);
        vector.addElement(3);
        vector.addElement(3);
        vector.addElement(3);
        vector.add("sdfsdf");
        //容量大小
        System.out.println(vector.capacity());
        //当前容器元素个数
        System.out.println(vector.size());
        System.out.println(vector.firstElement());
        System.out.println(vector.lastElement());
        System.out.println("----");
        Enumeration<Object> elements = vector.elements();
        while (elements.hasMoreElements()) {
            System.out.println(elements.nextElement());
        }

    }
}
